//
//  AppDelegate+ModuleEntry.m
//  DailyRecord
//
//  Created by Gin on 2022/4/17.
//

#import "AppDelegate+ModuleEntry.h"
#import "RootViewControllerOutPut.h"
#import "ThirdPartyManager.h"

@implementation AppDelegate (ModuleEntry)

- (void)enterToDailyModule{
    self.window = [[UIWindow alloc] initWithFrame:UIScreen.mainScreen.bounds];
    self.window.rootViewController = [RootViewControllerOutPut generateTabbarViewController];
    [ThirdPartyManager setUpThirdParty];
    [self addObserver];
    [self.window makeKeyAndVisible];
}

- (void)addObserver{
    [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(moduleMain) name:kNotificationLogined object:nil];
    [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(moduleMain) name:kNotificationLogout object:nil];
    [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(toLogin) name:kNotificationToLogin object:nil];
}

- (void)moduleMain{
    self.window.rootViewController = [RootViewControllerOutPut generateTabbarViewController];
}

- (void)toLogin{
    self.window.rootViewController = [RootViewControllerOutPut generateLoginViewController];
}

- (Boolean)isFinishCurrentModule{
    Boolean isFinish = [[NSUserDefaults standardUserDefaults] boolForKey:kFinishCurrentModule];
    return isFinish;
}


@end
